<style lang="less" scoped>
.panel {
  margin-bottom: 10px;
  &-title {
    display: flex;
    padding: 10px;
    border-bottom: 0.1px solid #eaeaea;
    background: white;

    &__label {
      flex: 1;
      font-size: 16px;
      align-items: center;
    }
    &__right {
      font-size: 14px;
    }
  }
  &-content {
    margin-bottom: 10px;
    background: white;

    &__item {
      display: flex;
      padding: 10px 10px 0 10px;
      font-size: 14px;
      &-label {
        color: #666;
        padding-right: 15px;
        // flex: 1;
      }
      &-value {
        flex: 1;
        // padding-left: 15px;
        color: #333;
        word-break: break-all;
      }
    }
  }
}
</style>

<template>
  <div>
    <!-- search on loading -->
    <load v-if="loading" />
    <div v-else class="panel">
      <template v-for="(item, index) in items" wx:key="unique">
        <!-- title -->
        <div class="panel-title" :key="'title'+index">
          <div class="panel-title__label c-primary">年度：{{item.Year||'-'}}</div>
          <div class="panel-title__right">纳税信用评级：【{{item.Level||'-'}}】</div>
        </div>
        <!-- content -->
        <div class="panel-content" :key="'content'+index">
          <div class="panel-content__item">
            <div class="panel-content__item-label">纳税人识别号:</div>
            <div class="panel-content__item-value">{{item.No||'-'}}</div>
            <div class="panel-content__item-right"></div>
          </div>
          <div class="panel-content__item">
            <div class="panel-content__item-label">纳税人名称:</div>
            <div class="panel-content__item-value">{{item.Name||'-'}}</div>
            <div class="panel-content__item-right"></div>
          </div>
        </div>
      </template>
    </div>
  </div>
</template>
<script>
import Load from '@/components/load';
export default {
  components: { Load },
  computed: {
    loading() {
      return this.$store.getters.loading;
    }
  },
  data() {
    return {
      items: []
    };
  },
  onLoad() {
    this.getInfos();
  },
  onUnload() {
    this.items = [];
  },
  methods: {
    async getInfos() {
      // 获取对外投资
      const url = '/app/getTaxesList';
      let unique = '';
      try {
        unique = this.$root.$mp.page.options.Unique;
      } catch (error) {}
      const params = {
        unique
      };

      const { status, message, result } = await this.$http.get(url, params);
      if (status !== 200) {
        wx.showToast({
          title: message || '查询失败！',
          icon: 'none',
          duration: 2000
        });
        return;
      }
      this.items = result;
    }
  }
};
</script>
